const DES = require('./index');

function ecb() {
  const des = new DES('ecb', '01234567');
  const plain = 'hello';
  const cipher = des.encrypt(plain);
  console.log('密文', cipher);
  const plain1 = des.decrypt(cipher);
  console.log('明文', plain1);
}

function cbc() {
  // cbc 模式下 key 和 iv 都是 8 个字符
  const des = new DES('cbc', '01234567', 'abcdefgh');
  const plain = 'hello';
  const cipher = des.encrypt(plain);
  console.log('密文', cipher);
  const plain1 = des.decrypt(cipher);
  console.log('明文', plain1);
}

function main() {
  ecb();
  cbc();
}

main();
